/**
 * 版权所有 2009-2015 中国中医科学院中医药信息研究所 何前锋 frontpeak@yahoo.com.cn
 **/
package cn.ac.cintcm.sh.domain;

public class Item implements Comparable {
    
    private NameValue nv;
    private Prescription prescription;

    
    public Item(String name, float value) {
        nv = new NameValue(name, value);
        prescription = new Prescription();
    }

    public NameValue getNv() {
        return nv;
    }
    public void setNv(NameValue nv) {
        this.nv = nv;
    }
    public Prescription getPrescription() {
        return prescription;
    }
    public void setPrescription(Prescription prescription) {
        this.prescription = prescription;
    }
    public void addValue(float f) {
        nv.setValue(nv.getValue() + f);
    }
    
    public String getName() {
        return nv.getName();
    }
    
    public float getValue() {
        return nv.getValue();
    }

    public void addHerb(Herb h) {
        prescription.addHerb(h);
    }

    public void addHerbs(Prescription p) {
        prescription.addHerbs(p);
        
    }

    public int compareTo(Object sp) {
        int compare = 1;
        if (sp != null && sp instanceof Item) {
            Item o = (Item) sp;
            compare = (int) ((o.getValue() - this.getValue()) * 100);
        }
        return compare;
    }

}